<section id="information">

    {% if analysis.detections %}
        <p  style="text-align:center; font-size: 18px;font-weight-bold";>Detection(s):
        {% for block  in analysis.detections %}
            <a href="/analysis/search/detections:{{block.family}}" data-toggle="tooltip" data-placement="top"><span class="badge badge-danger"  title="{% for subblock in block.details %}{% for k,v in subblock.items %}{{k}}{% if v %} -> {{v}}&#013;{% endif %}{% endfor %}{% endfor %}">{{block.family}}</span></a>
        {% endfor %}
        </p>
    {% endif %}

    {% if config.malscore and analysis.malstatus %}
        <p  style="text-align:center; font-size: 18px;font-weight-bold";>Status:
            {% if analysis.malstatus == "Malicious" %}
                <span class="badge badge-danger">{{analysis.malstatus}}</span>
            {% elif analysis.malstatus == "Suspicious" %}
                <span class="badge badge-warning">{{analysis.malstatus}}</span>
            {% elif analysis.malstatus == "Clean" %}
                <span class="badge badge-success">{{analysis.malstatus}}</span>
            {% else %}
                {{analysis.malstatus}}
         {% endif %}
        </p>
    {% endif %}

    <div class="panel panel-primary">
        <div class="panel-heading">
            <h4 class="panel-title">Analysis {% if settings.REPROCESS_TASKS %} <a class="btn btn-secondary btn-sm" href="{% url "reprocess_tasks" id %}" role="button" data-bs-toggle="tooltip" title="Reprocess the task"><span class="fa-solid fa-rotate"></span></a>{% endif %}</h4>
        </div>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>Category</th>
                    <th>Package</th>
                    <th>Started</th>
                    <th>Completed</th>
                    <th>Duration</th>
                    {% if analysis.info.options %}
                        <th>Options</th>
                    {% endif %}
                    {% if user.is_staff and analysis.distributed %}
                        <th>Distributed</th>
                    {% endif %}
                    <th>Log(s)</th>
                    {% if analysis.debug.pre_script_log %}
                        <th>Pre Script Logs</th>
                    {% endif %}
                    {% if analysis.debug.during_script_log %}
                        <th>During Script Logs</th>
                    {% endif %}
                    {% if config.malscore and analysis.malscore %}
                        <th>MalScore</th>
                    {% endif %}
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>{{analysis.info.category|upper}}</td>
                    <td>{{analysis.info.package}}</td>
                    <td>{{analysis.info.started}}</td>
                    <td>{{analysis.info.ended}}</td>
                    <td>{{analysis.info.duration}} seconds</td>
                    {% if analysis.info.options %}
                        <td><a class="accordion-toggle" data-toggle="collapse" href="#options">Show Options</a></td>
                    {% endif %}
                    {% if user.is_staff and analysis.distributed %}
                        <td>{{analysis.distributed.name}} - {{analysis.distributed.task_id}}</td>
                    {% endif %}
                    <td>
                        Show <a class="accordion-toggle" data-toggle="collapse" href="#info-log">Analysis</a>
                        {% if analysis.process_log %}
                            | <a class="accordion-toggle" data-toggle="collapse" href="#process-log"> Process</a>
                        {% endif %}
                        Log
                    </td>
                    {% if analysis.debug.pre_script_log %}
                        <td><a class="accordion-toggle" data-toggle="collapse" href="#info-pre-script-log">Show Pre Script</a></td>
                    {% endif %}
                    {% if analysis.debug.during_script_log %}
                        <td><a class="accordion-toggle" data-toggle="collapse" href="#info-during-script-log">Show During Script</a></td>
                    {% endif %}
                    {% if config.malscore and analysis.malscore %}
                    <td>
                        {% if analysis.malscore > 6.0 %}
                           <span class="badge badge-danger">{{analysis.malscore|floatformat:1}}</span>
                            {% elif analysis.malscore > 2.0 %}
                            <span class="badge badge-warning">{{analysis.malscore|floatformat:1}}</span>
                            {% else %}
                            <span class="badge badge-success">{{analysis.malscore|floatformat:1}}</span>
                        {% endif %}
                    </td>
                    {% endif %}
                </tr>
            </tbody>
        </table>
    </div>

    {% if analysis.debug.errors %}
        <ul style="font-size: 16px;">
        {% for error in analysis.debug.errors %}
            <li class="text-info"><b>Info:</b> {{error}}</li>
        {% endfor %}
        </ul>
    {% endif %}
    {% if analysis.info.options %}
        <div id="options" class="collapse">
            <pre>{% for key, val in analysis.info.options.items %}{{ key }}={{ val }}<br>{% endfor %}</pre>
        </div>
    {% endif %}
    <div id="info-log" class="collapse">
        <pre>{{analysis.debug.log}}</pre>
    </div>
    <div id="process-log" class="collapse">
        <pre>{{analysis.process_log}}</pre>
    </div>
    <div id="info-pre-script-log" class="collapse">
        <pre>{{analysis.debug.pre_script_log}}</pre>
    </div>
    <div id="info-during-script-log" class="collapse">
        <pre>{{analysis.debug.during_script_log}}</pre>
    </div>
</section>

{% if analysis.info.machine and analysis.info.machine.name %}
    <section id="machine">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h4 class="panel-title">Machine</h4>
            </div>
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Label</th>
                        <th>Manager</th>
                        <th>Started On</th>
                        <th>Shutdown On</th>
                        {% if analysis.info.route %}
                            <th>Route</th>
                        {% endif %}
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>{{analysis.info.machine.name}}</td>
                        <td>{{analysis.info.machine.label}}</td>
                        <td>{{analysis.info.machine.manager}}</td>
                        <td>{{analysis.info.machine.started_on}}</td>
                        <td>{{analysis.info.machine.shutdown_on}}</td>
                        {% if analysis.info.route %}
                            <td>{{analysis.info.route}}</td>
                        {% endif %}
                    </tr>
                </tbody>
            </table>
        </div>
    </section>
{% endif %}
